package day15.pool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExecutorDemo01 {
    public static void main(String[] args) {
        ThreadPoolExecutor tpe=new ThreadPoolExecutor(1,
                3,
                20,
                TimeUnit.SECONDS,new ArrayBlockingQueue<>(1),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardPolicy());
        for (int x = 0; x < 5; x++) {
            final  int y=x;
            tpe.submit(()->{
                System.out.println(Thread.currentThread().getName()+"------》执行了任务"+y);
            });
        }
    }
}
